package com.management.department.teacherinfosystem.Repository;
import com.management.department.teacherinfosystem.Entity.TeachingProjectMember;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface TeachingProjectMemberRepository extends JpaRepository<TeachingProjectMember, Long>{
    List<TeachingProjectMember> findByProjectId(@Param("projectId") Long projectId);
    List<TeachingProjectMember> findByUserId(@Param("userId") Long userId);
    
    @Modifying
    @Transactional
    @Query("DELETE FROM TeachingProjectMember tpm WHERE tpm.projectId = :projectId")
    void deleteByProjectId(@Param("projectId") Long projectId);
}
